/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * JServiceCalendarEditor.java
 *
 * Created on 2010-9-26, 9:56:59
 */

package cn.ekuma.epos.servings;

import java.util.Properties;

import cn.ekuma.data.ui.swing.AbstractParentDAOJEditor;
import cn.ekuma.data.ui.swing.JChildDAOEditorPanel;
import cn.ekuma.epos.datalogic.I_DataLogicSales;
import cn.ekuma.epos.servings.model.ServiceCalendarDayLineTableModel;
import cn.ekuma.epos.servings.model.ServiceCalendarWeakLineTableModel;
import com.openbravo.bean.ServiceCalendar;
import com.openbravo.data.basic.BasicException;
import com.openbravo.data.user.DirtyManager;
import com.openbravo.pos.base.AppLocal;


/**
 *
 * @author Administrator
 */
public class JServiceCalendarEditor extends AbstractParentDAOJEditor<ServiceCalendar,String> {

    I_DataLogicSales m_dlSales;

    JChildDAOEditorPanel dayLinePanel;
    JChildDAOEditorPanel weakLinePanel;

    /** Creates new form JServiceCalendarEditor */
    public JServiceCalendarEditor(I_DataLogicSales m_dlSales,DirtyManager dirty) {
        super(dirty);
        this.m_dlSales=m_dlSales;
        initComponents();
        jServiceCalendarName.getDocument().addDocumentListener(dirty);
        
        weakLinePanel=new  JChildDAOEditorPanel(m_dlSales,new ServiceCalendarWeakLineTableModel(),new JServiceCalendarWeakLineEditor(new DirtyManager()));
        jTabbedPane1.add(weakLinePanel.getTabName(), weakLinePanel);
        addObjectChangeListener(weakLinePanel);
        dayLinePanel=new JChildDAOEditorPanel(m_dlSales,new ServiceCalendarDayLineTableModel(),new JServiceCalendarDayLineEditor(new DirtyManager(),this));
        jTabbedPane1.add(dayLinePanel.getTabName(), dayLinePanel);
        addObjectChangeListener(dayLinePanel);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jServiceCalendarName = new javax.swing.JTextField();
        jTabbedPane1 = new javax.swing.JTabbedPane();

        setLayout(new java.awt.BorderLayout());

        jLabel1.setText(AppLocal.getIntString("label.serviceCalendar.name")); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jServiceCalendarName, javax.swing.GroupLayout.PREFERRED_SIZE, 184, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(92, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jServiceCalendarName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        add(jPanel1, java.awt.BorderLayout.PAGE_START);
        add(jTabbedPane1, java.awt.BorderLayout.CENTER);
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JTextField jServiceCalendarName;
    private javax.swing.JTabbedPane jTabbedPane1;
    // End of variables declaration//GEN-END:variables

    @Override
    public void updateUI(boolean editAble, int state) {
        jServiceCalendarName.setEditable(editAble);
    }

    public void refresh() {
    }

    @Override
    public ServiceCalendar createNew(Properties prop) {
        ServiceCalendar obj=new ServiceCalendar();
        return obj;
    }

    @Override
    public void rebuild(ServiceCalendar obj) throws BasicException {
        obj.setName(jServiceCalendarName.getText());
    }

    @Override
    public Class getEditClass() {
        return ServiceCalendar.class;
    }
}
